setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "ERROR : ".$e->getMessage(); } $sql = $DBcon->prepare("select sn from student ORDER BY sn DESC LIMIT 1"); $sql->execute() ; $row = $sql->FETCH(PDO::FETCH_ASSOC) ; $id = $row['sn'] ; $newid = $id + 1 ; $prfix = 'CFIS/0' ; $newuserid = $prfix.$newid ; //$pwd = $newid.'xchangex' ; return $newuserid ; //return $pwd ; } function newregno() { $DB_host = "localhost"; $DB_user = "u194461326_chinadmin"; $DB_pass = "China@2023"; $DB_name = "u194461326_chinaschool"; try { $DBcon = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass); $DBcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "ERROR : ".$e->getMessage(); } $sql = $DBcon->prepare("select sn from student ORDER BY sn DESC LIMIT 1"); $sql->execute() ; if($sql->rowcount() > 0) { $row = $sql->FETCH(PDO::FETCH_ASSOC) ; $id = $row['sn'] ; } else { $id = 0 ; } $newid = $id + 1 ; $yr = date('Y') ; $prfix = "CFIS/".$yr.'/0'; $newuserid = $prfix.$newid ; //$pwd = $newid.'xchangex' ; return $newuserid ; //return $pwd ; } function compressImage($source, $destination, $quality) { // Get image info $imgInfo = getimagesize($source); $mime = $imgInfo['mime']; // Create a new image from file switch($mime){ case 'image/jpeg': $image = imagecreatefromjpeg($source); imagejpeg($image, $destination, $quality); break; case 'image/png': $image = imagecreatefrompng($source); imagepng($image, $destination, $quality); break; case 'image/gif': $image = imagecreatefromgif($source); imagegif($image, $destination, $quality); break; default: $image = imagecreatefromjpeg($source); imagejpeg($image, $destination, $quality); } // Return compressed image return $destination; } ?>